﻿using Architecture.Common;
using B.S.BasicData.Api.Read.Application.Command.User;
using B.S.BasicData.Api.Read.DTOS;
using B.S.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Api.Read.Controllers
{
    [Route("api/[controller][action]")]
    [ApiController]
    [AllowAnonymous]
    public class LoginController : ControllerBase
    {
       IMediator _mediator;

        public LoginController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<UserLoginDto>>UserLogin([FromQuery]UserLoginCommand request)
        {
            return _mediator.Send(request);
        }
    }
}
